<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>  
<!DOCTYPE html>
<html>
<head>
<title>区域管理列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="decorator" content="default" />
<%@ include file="/WEB-INF/views/include/bootstrap-table.jsp"%>

<style type="text/css">
.date-field-class{
  width: 100px;
}

</style>
    
</head>
<body>
	<div class="boxcontent clearfix" style="margin-left: 0;">
		<div class="content clearfix" style="margin: 0;">
			<sys:message content="${message}"/>
			<form id="searchForm"  class="form-search">
				<div class="search-bar">
					<ul class="clearfix">
						<li>
							<span>区域名称：</span>
							<input id="name" name="name" class="form-control bootstrap-table-input"/>
						</li>
						<li>
							<span>区域编码：</span>
							<input id="code" name="code" class="form-control bootstrap-table-input"/>
						</li>
					</ul>
					<div id="btn_search" class="search-btn">查询</div>
					<script type="text/javascript">
						$(function(){
							$(".search-bar ul li").each(function(){
								var spanWidth = $(this).find("span").width();
								$(this).find(".form-control").width(230-20-spanWidth);	
								$(this).children(".input-append").find(".required").width(230-20-36+1-spanWidth);	
								var barHeight = $(".search-bar").height();
								$(".search-btn").css("line-height", barHeight+"px");
							});
						})
					</script>
				</div>
				
				<div id="toolbar">
				<shiro:hasPermission name="sys:area:create">
					<button type="button" class="btn-custom" onclick="createByTitle('sys/area/form','新增区域',false)">新增</button>
				</shiro:hasPermission>
				<shiro:hasPermission name="sys:area:delete">
					<button type="button" class="btn-custom btndelete" onclick="batchDelete('sys/area/batchDelete')">批量删除</button>
				</shiro:hasPermission>
					<button type="button" class="btn-custom" onclick="exportData('${ctx}/sys/area/export',this)">导出</button>
				</div>
			</form>
			
		<div class="tbbox firsttdCenter">
		
	    <table id="table" 
	         data-toggle="table" 
	         data-url="${ctx}/sys/area/areaListJson"
	         data-toolbar="#toolbar"
		     data-height="${dataHeight410}" 
		     data-maintain-selected="true" 
		     data-side-pagination="server"
		     data-click-to-select="true" 
		     data-pagination="true" 
		     data-single-select="false"
		     data-id-field="id"
		     data-query-params="doQuery"
		     data-cache="false"
		     data-show-columns="true"
		     data-page-list="${dataPageList}">
		<thead>
			<tr>
				<th data-checkbox="true"></th>
				<th data-field="id" data-formatter="operationFormatter" class="date-field-class">操作</th>
				<th data-field="name">区域名称</th>
				<th data-field="code">区域编码</th>
				<th data-field="type" data-formatter="typeFormatter">区域类型</th>
				<th data-field="remarks" data-visible="false">备注</th>
				<!-- data-sortable="true" 排序 -->
			    <!-- data-visible="false" 可以隐藏列 -->
			</tr>
		</thead>
	    </table>
	    </div>
	</div>
	
	<script type="text/javascript">
	  var $table = $('#table');
	  $(function () { 
          
	      $("#btn_search").click(function () { 
	              $table.bootstrapTable('refresh'); 
	       }); 
	   }); 
	  
	  //查询函数
	  function doQuery(params) {
		     var name_value = $("#name").val();
			 var code_value = $("#code").val();
			 var area_id = '${areaId}';
			 var parentIds = '${parentIds}';
			 
			if(name_value != null && name_value !=''){
				params.name = name_value;
			}
			if(code_value != null && code_value !=''){
				params.code = code_value;
			}
			if(area_id != null && area_id !='' && parentIds != null && parentIds !=''){
			//	alert(area_id);
				params.areaId = area_id;
				params.parentIds = parentIds;
			}
			
		    return params;
	}
	
	
	/**
	*  操作项  add for lgx  提供查看，修改，删除按钮，如果还有系统按钮，
	*  比如禁用，可在子页面进行自定义函数添加（建议列表操作项按钮不要超过5个）
	*/
	
	var hasView = '${fns:hasPermission("sys:area:view")}';
	var hasEdit = '${fns:hasPermission("sys:area:edit")}';
	var hasDelete = '${fns:hasPermission("sys:area:delete")}';
	
	function operationFormatter(value, row){
		
		var params = "id="+value;
		//查看
		//var html = '<a href="javascript:void(0);" style="padding-right:5px;" onclick="detail(\'sys/role/roleDetail\',\'查看角色\',\''+params+'\')">查看</a>';
		
		var html = '';
		
	    if(hasEdit == 'true'){
	    	html = html + '<a href="javascript:void(0);" style="padding-right:5px;" onclick="modify(\'sys/area/form\',\'修改区域管理\',\''+params+'\')">修改</a>';
		}else{
			html = html + '<span style="padding-right:5px;" title="您没有操作权限">修改</span>';
		} 

	    if(hasDelete == 'true'){
			//删除
			html= html  + '<a href="javascript:void(0);" onclick="deleteData(\'sys/area/deleteAjax\',\'是否删除数据？\',\''+params+'\')">删除</a>';
	    }else{
	    	html = html + '<span style="padding-right:5px;" title="您没有操作权限">删除</span>';
	    }

		
		return html;
	}  
	
	function typeFormatter(value, row){
		   var data = ${fns:getDictListJson('sys_area_type')}; 
		   value = getDictLabel(data,value,'-');
		   return value;
	}
	</script>
	
	<jsp:include page="/WEB-INF/views/include/pageJs.jsp" />
</body>
</html>